package com.whatever;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.*;

public class DrawView extends View implements OnTouchListener {
	public ColorBall colorBall;
	public ColorBall colorBall2;
	private Paint paint;
	
	public DrawView(Context context) {
		super(context);
		colorBall = new ColorBall(context, 30, 30);
		colorBall2 = new ColorBall(context, 50, 50);
		
		setFocusableInTouchMode(true);
		setOnTouchListener(this);
	}
	
	public void onDraw(Canvas canvas) {
		canvas.drawColor(Color.BLACK);
		
		colorBall.onMove(5, 5, colorBall);
		colorBall2.onMove(5, 5, colorBall);
		
		paint = new Paint();
		paint.setColor(Color.RED);
		paint.setAntiAlias(true);
		
		canvas.drawCircle(colorBall.getX(), colorBall.getY(), 25, paint);
		paint.setColor(Color.YELLOW);
		canvas.drawCircle(colorBall2.getX(), colorBall2.getY(), 25, paint);
		invalidate();
	}

	public boolean onTouch(View v, MotionEvent event) {
		colorBall.setX((int)event.getX());
		colorBall.setY((int)event.getY());
		colorBall2.setX((int)event.getX());
		colorBall2.setY((int)event.getX());
		
		invalidate();
		colorBall.setRandomVelocity();
		colorBall2.setRandomVelocity();
		
		return true;
	}
}
